<template>
  <div class="module card">
    <div class="module-header">
      <h2><el-icon><Tools /></el-icon> 常用工具</h2>
<!--      <a href="#" class="more-link">更多 <el-icon><ArrowRight /></el-icon></a>-->
    </div>
    <div class="module-body">
      <div class="tools-container">
        <div
            class="tool-item"
            v-for="tool in tools"
            :key="tool.name"
            @click="handleToolClick(tool)"
        >
          <div class="tool-icon">
            <component :is="tool.icon" />
          </div>
          <div class="tool-name">{{ tool.name }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps } from 'vue';
import { useRouter } from 'vue-router';
import {
  Tools, ArrowRight,
  Clock, BellFilled, DocumentDelete,
  DocumentChecked, Upload, Collection,
  Calendar, StarFilled, Operation, Trophy, School
} from '@element-plus/icons-vue';

const props = defineProps({
  tools: {
    type: Array,
    required: true,
    default: () => [
      {name: '打卡', icon: Clock},
      {name: '通知', icon: BellFilled},
      {name: '请假', icon: DocumentDelete},
      {name: '问卷调查', icon: DocumentChecked},
      {name: '上传成果', icon: Upload},
      {name: '课程资源', icon: Collection}
    ]
  }
});

const router = useRouter();

const handleToolClick = (tool) => {
  console.log(`点击工具: ${tool.name}`);

  // 根据工具名称进行路由跳转
  switch (tool.name) {
    case '打卡':
      router.push('/teacher/activities');
      break;
    case '通知':
      ElMessage.info('「通知」功能正在开发中，敬请期待！');
      break;
    case '请假':
      ElMessage.info('「请假」功能正在开发中，敬请期待！');
      break;
    case '课程表':
      router.push('/teacher/courses');
      break;
    case '资源库':
      router.push('/teacher/courses?tab=resources');
      break;
    case '教师评价':
      // 跳转到教师评价页面
      ElMessage.info('「教师评价」功能正在开发中，敬请期待！');
      break;
    case '问卷调查':
      router.push('/teacher/activities?type=survey');
      break;
    case '活动管理':
      router.push('/teacher/activities');
      break;
    case '成果管理':
      // 跳转到成果管理页面
      ElMessage.info('「成果管理」功能正在开发中，敬请期待！');
      break;
    case '班级管理':
      router.push('/teacher/classes');
      break;
    default:
      // 对于未实现的功能，显示提示信息
      ElMessage.info(`「${tool.name}」功能正在开发中，敬请期待！`);
      break;
  }
};

</script>

<style scoped>
/* 原有的样式保持不变 */
.module {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

.module:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.module-header {
  position: relative;
  padding: 16px 20px;
  background: #1e62ec;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.module-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.more-link {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.3s;
}

.more-link:hover {
  color: white;
  text-decoration: underline;
}

.module-body {
  padding: 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.tools-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: flex-start;
  align-items: flex-start;
}

.tool-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90px;
  cursor: pointer;
  transition: transform 0.3s;
}

.tool-item:hover {
  transform: translateY(-5px);
}

.tool-icon {
  width: 60px;
  height: 60px;
  background: #f5f7fa;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  transition: background 0.3s;
}

.tool-item:hover .tool-icon {
  background: #e8f4ff;
}

.tool-icon svg {
  width: 30px;
  height: 30px;
  color: #1e62ec;
}

.tool-name {
  font-size: 14px;
  color: #606266;
  text-align: center;
  line-height: 1.4;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .tool-item {
    width: 80px;
  }

  .tool-icon {
    width: 50px;
    height: 50px;
  }

  .tool-icon svg {
    width: 25px;
    height: 25px;
  }
}

@media (max-width: 992px) {
  .tools-container {
    gap: 15px;
  }

  .tool-item {
    width: 75px;
  }
}

@media (max-width: 768px) {
  .tools-container {
    gap: 10px;
  }

  .tool-item {
    width: 70px;
  }

  .tool-icon {
    width: 45px;
    height: 45px;
  }

  .tool-icon svg {
    width: 22px;
    height: 22px;
  }

  .tool-name {
    font-size: 13px;
  }
}
</style>
